<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>修改页面</title>
    <!--1.引入bootstrap样式框架；-->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">

    <!--2.引入angularJS分页样式的框架；-->
    <link rel="stylesheet" href="angularjs/pagination.css">

    <link rel="stylesheet" href="layer/theme/default/layer.css">

    <!--3.引入bootstrap中的Jquery框架；-->
    <script src="bootstrap/js/jquery.min.js"></script>
    <!--4.引入bootstrap中的Js框架；-->
    <script src="bootstrap/js/bootstrap.min.js"></script>

    <script src="//cdn.bootcss.com/angular.js/1.5.8/angular.min.js"></script>
    <script src="//cdn.bootcss.com/angular.js/1.5.8/angular-route.js"></script>

    <!--<script src="//unpkg.com/angular-ui-router@0.4.2/release/angular-ui-router.js"></script>-->
    <!--6.引入AngularJS分布的JS框架-->
    <script src="angularjs/pagination.js"></script>

    <script src="layer/layer.js"></script>

    <!--9.定义自己写的 javascript 代码：-->

</head>
<body ng-app="editApp" ng-controller="editController">
<div>
    <ol class="breadcrumb" style="margin-top: 0px;margin-bottom: 0;">
        <li><a >Home</a></li>
        <li><a >银行</a></li>
        <li><a href="index.html">返回首页</a></li>
    </ol>
</div>
<div class="container">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h1>银行卡冻结</h1>
        </div>

        <div class="panel-body">

            <div class="col-md-9 col-md-offset-1">

                <div class="form-group">
                    <div class="form-horizontal">
                        <label for="bankAccount" class="control-label col-md-2">银行卡号：</label>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                            <input name="bankAccount" id="bankAccount" class="form-control" ng-model="from.bankAccount" placeholder="请输入银行卡号" maxlength="19"
                                   type="text"/>
                        </div>
                    </div><br>

                    <div class="form-horizontal">
                        <label for="ukNumber" class="control-label col-md-2">身份证号：</label>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                            <input name="ukNumber" id="ukNumber" class="form-control" ng-model="from.ukNumber" placeholder="请输入身份证号" maxlength="30"
                                   type="text"/>
                        </div>
                    </div><br>

                    <div class="form-horizontal">
                        <label for="bankPwd" class="control-label col-md-2">银行卡密码：</label>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                            <input name="bankPwd" id="bankPwd" class="form-control" ng-model="from.bankPwd" placeholder="请输入密码" ng-blur="check()" maxlength="30"
                                   type="password"/>
                        </div>
                    </div><br>


                    <div class="form-horizontal">
                        <label for="phone" class="control-label col-md-2">手机号</label>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                            <input name="phone" id="phone" ng-model="from.mobile" placeholder="请输入手机号码" class="form-control" maxlength="30"
                                   style="width: 80%" type="text"><span id="phone2"></span>&nbsp;&nbsp;&nbsp;
                            <input class="form-control" ng-click="getCode()" ng-disabled="isDisable" id="sjh" style="width: 15%;margin-left: 17px;color: white;background-color: #40AFFE" value="发送" type="button">
                        </div>

                    </div><br>

                    <div class="form-horizontal">
                        <label for="yzm" class="control-label col-md-2">短信验证码：</label>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                            <input name="upwd" id="yzm" class="form-control" ng-model="from.checkCode" placeholder="请输入短信中的验证码" maxlength="30"
                                   type="text"/>
                        </div>
                    </div><br>

                    <div class="form-group">
                        <div class="form-group">
                            <input class="btn btn-primary col-sm-offset-2 col-md-10" id="submit"
                                   ng-click="submit()"     value="确认" type="button">
                        </div>

                    </div><br>

                </div>

            </div>


        </div>

        <div class="panel-footer text-right">
            viko
        </div>
    </div>
</div>

<script>
    layerindex=-1;
    var app = angular.module('editApp',[]);
    app.controller('editController', function ($scope, $http) {
        $scope.change = false;

        $scope.from={
            bankAccount:"",
            ukNumber:"",
            bankPwd:"",
            checkCode:"",
            mobile:""
        }
        $scope.isDisable = false;

        $http.post('http://localhost:12000/tran/ip').then(function (data) {  //正确请求成功时处理
            console.log(data)
            if (data.data.code == 403) {
                window.location.href = "/login.html";
            }
        }).catch(function (result) { //捕捉错误处理
            console.info(result);
        });

        $scope.getCode = function () {

            var phone=$("#phone").val();
            if($scope.from.mobile==""){
                alert("手机号不能为空");
            }else{
                $http.post("http://127.0.0.1:12000/user/frozen/sendNew?mobile="+$scope.from.mobile).success(function (data) {
                    console.log("data="+data);
                    if (data = "success") {
                        alert("成功发送！");
                        $scope.n = 60;
                        $scope.text = $scope.n + "秒后再点击";
                        $scope.isDisable = true;

                        var time = setInterval(function () {
                            console.log("hello");
                            $scope.n--;
                            $scope.$apply(function(){
                                $scope.text = $scope.n + "秒后再点击";
                            });
                            //console.log($scope.n);
                            if ($scope.n == 0)
                            {
                                $scope.$apply(function(){
                                    $scope.isDisable = false;
                                    $scope.text = "获取验证码";
                                });
                                clearInterval(time);
                            }

                        },1000);
                    } else {
                        alert("服务器繁忙，请重新发送");
                    }
                })

            }
        };


        $scope.submit= function () {
            $http.post("http://127.0.0.1:12000/user/frozen/verify?bankAccount="
                +$scope.from.bankAccount+"&ukNumber="+$scope.from.ukNumber+"&bankPwd="+$scope.from.bankPwd+"&checkCode="+$scope.from.checkCode)
                .success(function (data) {
                    console.log(data);
                    if(data.code==200){
                        layer.close(layerindex);
                        layer.msg(data.msg,{icon:6,title:"系统提示："});
                        alert(data.msg);
                        window.location.href="/index.html";
                    }else{
                        alert(data.msg);
                    }
            })
        };



    });
</script>
</body>
</html>
